﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Things.Bar.Models;
using Things.Bar;

namespace Things.Web.Bar
{
    public partial class DeleteNotice : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Notice notice = GetModel();
            if (notice != null)
            {
                new NoticeRepository().Delete(notice);
            }
            Response.Redirect("./NoticeList.aspx");
        }

        protected Notice GetModel()
        {
            Notice model = null;
            if (string.IsNullOrEmpty(Request["noticeid"]) == false)
            {
                Guid id = new Guid(Request["noticeid"]);
                NoticeRepository rep = new NoticeRepository();
                model = rep.Find(id);
            }
            return model;
        }
    }
}